package com.example.feignconsumer.service;

import com.example.commons.Book;
import com.example.feignconsumer.service.fallback.HelloServiceFallback;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 使用注解来绑定服务提供者提供的接口
 * 绑定了一个名叫hello-service(这里hello-service大小写无所谓)的服务提供者
 */
@FeignClient(value = "demo-provider-service", fallback = HelloServiceFallback.class)
public interface HelloService {

    /**
     * 消费一个名叫hello-service的服务提供者提供的/hello接口
     * @return
     */
    @RequestMapping("/service/hello")
    String hello();

    @RequestMapping(value = "/service/hello1", method = RequestMethod.GET)
    String hello(@RequestParam("name") String name);

    @RequestMapping(value = "/service/hello2", method = RequestMethod.GET)
    Book hello(@RequestHeader("name") String name, @RequestHeader("author") String author, @RequestHeader("price") Integer price);

    @RequestMapping(value = "/service/hello3", method = RequestMethod.POST)
    String hello(@RequestBody Book book);

    @RequestMapping(value = "/service/foo", method = RequestMethod.GET)
    String foo(@RequestParam("name") String name);

}
